package com.modern.util;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;
import java.util.Map;

public class JwtUtil {
    private static String key="siahjsdkwiohiu";
    private static long validTime=600000000L;
    public static String getToken(Map<String,Object> claims){
        return Jwts.builder()
                .addClaims(claims)
                .signWith(SignatureAlgorithm.HS256,key)
                .setExpiration(new Date(System.currentTimeMillis()+validTime))
                .compact();
    }
    public static Claims parseToken(String token){
        Claims body=Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
        return body;
    }
}
